
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Eventloop · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="four-operations-1.html" />
    
    
    <link rel="prev" href="eslint-vscode-format.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    前端进阶
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="Grid System.html">
            
                <a href="Grid System.html">
            
                    
                    Grid System
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="Handwritten signature.html">
            
                <a href="Handwritten signature.html">
            
                    
                    Handwritten Signature
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Mobile Soft Keyboard.html">
            
                <a href="Mobile Soft Keyboard.html">
            
                    
                    Mobile Soft Keyboard
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="authentication.html">
            
                <a href="authentication.html">
            
                    
                    Authentication
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    Code
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" >
            
                <span>
            
                    
                    Four Operations
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="control loading.html">
            
                <a href="control loading.html">
            
                    
                    Control Loading
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="downfile.html">
            
                <a href="downfile.html">
            
                    
                    Downfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="dynamic-routing.html">
            
                <a href="dynamic-routing.html">
            
                    
                    Dynamic Routing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="ecs.html">
            
                <a href="ecs.html">
            
                    
                    Ecs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="engineering.html">
            
                <a href="engineering.html">
            
                    
                    Engineering
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="eslint-vscode-format.html">
            
                <a href="eslint-vscode-format.html">
            
                    
                    Eslint Vscode Format
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.14" data-path="eventloop.html">
            
                <a href="eventloop.html">
            
                    
                    Eventloop
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="four-operations-1.html">
            
                <a href="four-operations-1.html">
            
                    
                    Four Operations 1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="four-operations-2.html">
            
                <a href="four-operations-2.html">
            
                    
                    Four Operations 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="four-operations-3.html">
            
                <a href="four-operations-3.html">
            
                    
                    Four Operations 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="four-operations-4.html">
            
                <a href="four-operations-4.html">
            
                    
                    Four Operations 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="front end summary.html">
            
                <a href="front end summary.html">
            
                    
                    Front End Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="git commit style.html">
            
                <a href="git commit style.html">
            
                    
                    Git Commit Style
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="git-commands.html">
            
                <a href="git-commands.html">
            
                    
                    Git Commands
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="high-quality-code.html">
            
                <a href="high-quality-code.html">
            
                    
                    High Quality Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="history.html">
            
                <a href="history.html">
            
                    
                    History
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="html-tag.html">
            
                <a href="html-tag.html">
            
                    
                    Html Tag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="http-https-http2.html">
            
                <a href="http-https-http2.html">
            
                    
                    Http Https Http2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="ignore log.html">
            
                <a href="ignore log.html">
            
                    
                    Ignore Log
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" >
            
                <span>
            
                    
                    Imgs
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.28" data-path="javascript-optimization.html">
            
                <a href="javascript-optimization.html">
            
                    
                    Javascript Optimization
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.29" data-path="local application.html">
            
                <a href="local application.html">
            
                    
                    Local Application
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.30" data-path="locality.html">
            
                <a href="locality.html">
            
                    
                    Locality
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.31" data-path="loop-unrolling.html">
            
                <a href="loop-unrolling.html">
            
                    
                    Loop Unrolling
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.32" data-path="mobile recommendation.html">
            
                <a href="mobile recommendation.html">
            
                    
                    Mobile Recommendation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.33" data-path="modal.html">
            
                <a href="modal.html">
            
                    
                    Modal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.34" data-path="monitor.html">
            
                <a href="monitor.html">
            
                    
                    Monitor
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.35" data-path="performance.html">
            
                <a href="performance.html">
            
                    
                    Performance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.36" data-path="print-talbe.html">
            
                <a href="print-talbe.html">
            
                    
                    Print Talbe
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.37" data-path="promise.html">
            
                <a href="promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.38" data-path="teaching.html">
            
                <a href="teaching.html">
            
                    
                    Teaching
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.39" data-path="vue refresh.html">
            
                <a href="vue refresh.html">
            
                    
                    Vue Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.40" data-path="vue-page-not-refresh.html">
            
                <a href="vue-page-not-refresh.html">
            
                    
                    Vue Page Not Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.41" data-path="why-learn-theory.html">
            
                <a href="why-learn-theory.html">
            
                    
                    Why Learn Theory
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Eventloop</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x540C;&#x6B65;&#x3001;&#x5F02;&#x6B65;">&#x540C;&#x6B65;&#x3001;&#x5F02;&#x6B65;</h2>
<p>JS&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#x7684;&#xFF0C;&#x6BCF;&#x6B21;&#x53EA;&#x80FD;&#x505A;&#x4E00;&#x4EF6;&#x4E8B;&#x60C5;&#x3002;&#x50CF;&#x4EE5;&#x4E0B;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x4EE3;&#x7801;&#x4F1A;&#x6309;&#x987A;&#x5E8F;&#x6267;&#x884C;&#xFF0C;&#x8FD9;&#x4E2A;&#x5C31;&#x53EB;&#x540C;&#x6B65;&#x3002; </p>
<pre><code>console.log(1);
console.log(2);
console.log(3);
</code></pre><p>&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x4F1A;&#x8F93;&#x51FA;2&#x3001;3&#x3001;1&#xFF0C;&#x50CF;&#x8FD9;&#x79CD;&#x4E0D;&#x6309;&#x987A;&#x5E8F;&#x6267;&#x884C;&#x7684;&#xFF0C;&#x6216;&#x8005;&#x8BF4;&#x4EE3;&#x7801;&#x6267;&#x884C;&#x4E2D;&#x95F4;&#x6709;&#x65F6;&#x95F4;&#x95F4;&#x9699;&#x7684;&#xFF0C;&#x53EB;&#x5F02;&#x6B65;&#x3002;</p>
<pre><code>setTimeout(() =&gt; {
    console.log(1);
}, 0);
console.log(2);
console.log(3);
</code></pre><h2 id="&#x4E8B;&#x4EF6;&#x5FAA;&#x73AF;">&#x4E8B;&#x4EF6;&#x5FAA;&#x73AF;</h2>
<p>&#x4E00;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x901A;&#x5E38;&#x6709;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x5E38;&#x9A7B;&#x7684;&#x7EBF;&#x7A0B;&#xFF1A;</p>
<ul>
<li>&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x7EBF;&#x7A0B;&#xFF1A;&#x8BE5;&#x7EBF;&#x7A0B;&#x8D1F;&#x8D23;&#x9875;&#x9762;&#x7684;&#x6E32;&#x67D3;</li>
<li>JS&#x5F15;&#x64CE;&#x7EBF;&#x7A0B;&#xFF1A;&#x8D1F;&#x8D23;JS&#x7684;&#x89E3;&#x6790;&#x548C;&#x6267;&#x884C;</li>
<li>&#x5B9A;&#x65F6;&#x89E6;&#x53D1;&#x5668;&#x7EBF;&#x7A0B;&#xFF1A;&#x5904;&#x7406;&#x5B9A;&#x65F6;&#x4E8B;&#x4EF6;&#xFF0C;&#x6BD4;&#x5982;setTimeout, setInterval</li>
<li>&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x7EBF;&#x7A0B;&#xFF1A;&#x5904;&#x7406;DOM&#x4E8B;&#x4EF6;</li>
<li>&#x5F02;&#x6B65;http&#x8BF7;&#x6C42;&#x7EBF;&#x7A0B;&#xFF1A;&#x5904;&#x7406;http&#x8BF7;&#x6C42;</li>
</ul>
<p>&#x6E32;&#x67D3;&#x7EBF;&#x7A0B;&#x548C;JS&#x5F15;&#x64CE;&#x7EBF;&#x7A0B;&#x662F;&#x4E0D;&#x80FD;&#x540C;&#x65F6;&#x8FDB;&#x884C;&#x7684;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5728;&#x6267;&#x884C;&#x4EE3;&#x7801;&#x65F6;&#xFF0C;&#x6E32;&#x67D3;&#x4F1A;&#x6302;&#x8D77;&#xFF1B;&#x6E32;&#x67D3;DOM&#x65F6;&#xFF0C;&#x4EE3;&#x7801;&#x4E5F;&#x4E0D;&#x4F1A;&#x6267;&#x884C;&#x3002;
&#x867D;&#x7136;JS&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#xFF0C;&#x4F46;&#x662F;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x591A;&#x7EBF;&#x7A0B;&#x7684;&#xFF0C;&#x5728;&#x9047;&#x5230;&#x50CF;setTimeout&#x3001;DOM&#x4E8B;&#x4EF6;&#x3001;ajax&#x7B49;&#x8FD9;&#x79CD;&#x4EFB;&#x52A1;&#x65F6;&#xFF0C;&#x4F1A;&#x8F6C;&#x4EA4;&#x7ED9;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x5176;&#x4ED6;&#x5DE5;&#x4F5C;&#x7EBF;&#x7A0B;(&#x4E0A;&#x9762;&#x63D0;&#x5230;&#x7684;&#x51E0;&#x4E2A;&#x7EBF;&#x7A0B;)&#x6267;&#x884C;&#xFF0C;&#x6267;&#x884C;&#x5B8C;&#x4E4B;&#x540E;&#x5C06;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x653E;&#x5165;&#x5230;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x3002;</p>
<pre><code>// eventLoop&#x662F;&#x4E00;&#x4E2A;&#x7528;&#x4F5C;&#x961F;&#x5217;&#x7684;&#x6570;&#x7EC4;
// &#xFF08;&#x5148;&#x8FDB;&#xFF0C;&#x5148;&#x51FA;&#xFF09;
var eventLoop = [ ];
var event;
// &#x201C;&#x6C38;&#x8FDC;&#x201D;&#x6267;&#x884C;
while (true) {
    // &#x4E00;&#x6B21;tick
    if (eventLoop.length &gt; 0) {
        // &#x62FF;&#x5230;&#x961F;&#x5217;&#x4E2D;&#x7684;&#x4E0B;&#x4E00;&#x4E2A;&#x4E8B;&#x4EF6;
        event = eventLoop.shift();
        // &#x73B0;&#x5728;&#xFF0C;&#x6267;&#x884C;&#x4E0B;&#x4E00;&#x4E2A;&#x4E8B;&#x4EF6;
        event();
    }
}
</code></pre><p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x6765;&#x60F3;&#x50CF;&#x4E00;&#x4E0B;JS&#x7684;&#x6267;&#x884C;&#x60C5;&#x51B5;&#x3002;<br>
JS&#x4E3B;&#x7EBF;&#x7A0B;&#xFF0C;&#x5C31;&#x50CF;&#x662F;&#x4E00;&#x4E2A;while&#x5FAA;&#x73AF;&#xFF0C;&#x4F1A;&#x4E00;&#x76F4;&#x6267;&#x884C;&#x4E0B;&#x53BB;&#x3002;&#x5728;&#x8FD9;&#x671F;&#x95F4;&#xFF0C;&#x6BCF;&#x6B21;&#x90FD;&#x4F1A;&#x67E5;&#x770B;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6709;&#x6CA1;&#x6709;&#x9700;&#x8981;&#x6267;&#x884C;&#x7684;&#x4EFB;&#x52A1;&#xFF08;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#xFF09;&#x3002;&#x5728;&#x6267;&#x884C;&#x5B8C;&#x4E00;&#x4E2A;&#x4EFB;&#x52A1;&#x4E4B;&#x540E;&#xFF0C;
&#x4F1A;&#x7EE7;&#x7EED;&#x4E0B;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;&#xFF0C;&#x76F4;&#x5230;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6240;&#x6709;&#x4EFB;&#x52A1;&#x90FD;&#x6267;&#x884C;&#x5B8C;&#x4E3A;&#x6B62;&#x3002;</p>
<h2 id="microtask&#x5FAE;&#x4EFB;&#x52A1;&#x3001;macrotask&#x5B8F;&#x4EFB;&#x52A1;">microtask(&#x5FAE;&#x4EFB;&#x52A1;)&#x3001;macrotask(&#x5B8F;&#x4EFB;&#x52A1;)</h2>
<p>&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x53C8;&#x5206;&#x5FAE;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x548C;&#x5B8F;&#x4EFB;&#x52A1;&#x961F;&#x5217;</p>
<h3 id="&#x5FAE;&#x4EFB;&#x52A1;">&#x5FAE;&#x4EFB;&#x52A1;</h3>
<ul>
<li>Promise</li>
<li>MutationObserver&#xFF08;Mutation Observer API &#x7528;&#x6765;&#x76D1;&#x89C6; DOM &#x53D8;&#x52A8;&#xFF09;</li>
<li>Object.observe()&#xFF08;&#x5DF2;&#x5E9F;&#x5F03;&#xFF09;</li>
</ul>
<h3 id="&#x5B8F;&#x4EFB;&#x52A1;">&#x5B8F;&#x4EFB;&#x52A1;</h3>
<ul>
<li>setTimeout</li>
<li>setInterval</li>
<li>setImmediate</li>
<li>I\O</li>
<li>UI rendering(DOM event)</li>
</ul>
<h2 id="&#x6267;&#x884C;&#x8FC7;&#x7A0B;">&#x6267;&#x884C;&#x8FC7;&#x7A0B;</h2>
<ol>
<li>&#x5728;JS&#x6267;&#x884C;&#x5B8C;&#x540C;&#x6B65;&#x4EFB;&#x52A1;&#x4E4B;&#x540E;&#xFF0C;&#x4F1A;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x5FAE;&#x4EFB;&#x52A1;&#x961F;&#x5217;</li>
<li>&#x5728;&#x5C06;&#x6240;&#x6709;&#x7684;&#x5FAE;&#x4EFB;&#x52A1;&#x6267;&#x884C;&#x5B8C;&#x4E4B;&#x540E;&#xFF0C;&#x4F1A;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x5B8F;&#x4EFB;&#x52A1;&#x961F;&#x5217;</li>
<li>&#x5728;&#x6267;&#x884C;&#x5B8C;&#x4E00;&#x4E2A;&#x5B8F;&#x4EFB;&#x52A1;&#x4E4B;&#x540E;&#xFF0C;&#x8DF3;&#x51FA;&#x6765;&#xFF0C;&#x91CD;&#x65B0;&#x5F00;&#x59CB;&#x4E0B;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;(&#x4ECE;1&#x5F00;&#x59CB;&#x6267;&#x884C;)</li>
</ol>
<p>&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6267;&#x884C;&#x5FAE;&#x4EFB;&#x52A1;&#x961F;&#x5217; &#x4F1A;&#x5C06;&#x961F;&#x5217;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x5FAE;&#x4EFB;&#x52A1;&#x6267;&#x884C;&#x5B8C; &#x800C;&#x6267;&#x884C;&#x5B8F;&#x4EFB;&#x52A1;&#x961F;&#x5217; &#x6BCF;&#x6B21;&#x53EA;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x5B8F;&#x4EFB;&#x52A1; &#x7136;&#x540E;&#x91CD;&#x65B0;&#x5F00;&#x59CB;&#x4E0B;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;
&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x770B;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;</p>
<pre><code>setTimeout(() =&gt; {
    console.log(3)
    new Promise((resolve, reject) =&gt; {
        console.log(5)
        resolve()
    }).then(console.log(6))
}, 0)

setTimeout(() =&gt; {
    console.log(4)
}, 0)

new Promise((resolve, reject) =&gt; {
    console.log(1)
    resolve()
}).then(console.log(2))
</code></pre><p>&#x8F93;&#x51FA;&#x662F;1 2 3 5 6 4</p>
<p>&#x6211;&#x4EEC;&#x6765;&#x5206;&#x6790;&#x4E00;&#x4E0B;&#x4EE3;&#x7801;&#x7684;&#x6267;&#x884C;&#x8FC7;&#x7A0B;</p>
<ol>
<li>&#x524D;&#x9762;&#x7684;&#x4E24;&#x4E2A;setTimeout&#x90FD;&#x662F;&#x5B8F;&#x4EFB;&#x52A1;&#xFF0C;&#x6240;&#x4EE5;&#x73B0;&#x5728;&#x5B8F;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6709;2&#x4E2A;&#x4EFB;&#x52A1;</li>
<li>Promise&#x91CC;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x662F;&#x540C;&#x6B65;&#x4EFB;&#x52A1;&#xFF0C;&#x6240;&#x4EE5;&#x73B0;&#x5728;&#x4F1A;&#x9A6C;&#x4E0A;&#x6267;&#x884C; &#x8F93;&#x51FA;1</li>
<li>Promise&#x7684;then&#x662F;&#x5FAE;&#x4EFB;&#x52A1;&#xFF0C;&#x6240;&#x4EE5;&#x73B0;&#x5728;&#x5FAE;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6709;1&#x4E2A;&#x4EFB;&#x52A1;</li>
<li>&#x5728;&#x6267;&#x884C;&#x5B8C;&#x540C;&#x6B65;&#x4EFB;&#x52A1;&#x4E4B;&#x540E;&#xFF0C;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x5FAE;&#x4EFB;&#x52A1;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;console.log(2), &#x8F93;&#x51FA;2</li>
<li>&#x5728;&#x6267;&#x884C;&#x5B8C;&#x5FAE;&#x4EFB;&#x52A1;&#x4E4B;&#x540E;&#xFF0C;&#x4F1A;&#x6267;&#x884C;&#x5B8F;&#x4EFB;&#x52A1;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x5B8F;&#x4EFB;&#x52A1;&#x4E5F;&#x5C31;&#x662F;&#x7B2C;&#x4E00;&#x4E2A;setTimeout</li>
<li>&#x7B2C;&#x4E00;&#x4E2A;setTimeout&#x4F1A;&#x5148;&#x8F93;&#x51FA;3&#xFF0C;&#x7136;&#x540E;&#x8F93;&#x51FA;5&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4E24;&#x4E2A;&#x90FD;&#x662F;&#x540C;&#x6B65;&#x4EFB;&#x52A1;&#xFF0C;&#x7136;&#x540E;&#x9047;&#x5230;then&#xFF0C;&#x52A0;&#x5165;&#x5FAE;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#xFF0C;&#x5B8F;&#x4EFB;&#x52A1;&#x6267;&#x884C;&#x5B8C;&#x91CD;&#x65B0;&#x5F00;&#x59CB;&#x4E0B;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;&#x3002;</li>
<li>&#x56E0;&#x4E3A;&#x6CA1;&#x6709;&#x540C;&#x6B65;&#x4EE3;&#x7801;&#xFF0C;&#x6240;&#x4EE5;&#x63A5;&#x7740;&#x6267;&#x884C;&#x5FAE;&#x4EFB;&#x52A1;&#xFF0C;&#x6B64;&#x65F6;&#x5FAE;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6709;1&#x4E2A;&#x4EFB;&#x52A1;(&#x7B2C;6&#x6B65;&#x52A0;&#x5165;), &#x5B8F;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x8FD8;&#x6709;1&#x4E2A;&#x4EFB;&#x52A1;(&#x7B2C;6&#x6B65;&#x6267;&#x884C;&#x5B8C;&#x4E86;&#x7B2C;&#x4E00;&#x4E2A;&#x5B8F;&#x4EFB;&#x52A1;)</li>
<li>&#x6267;&#x884C;&#x5FAE;&#x4EFB;&#x52A1;&#xFF0C;&#x8F93;&#x51FA;6</li>
<li>&#x518D;&#x6267;&#x884C;&#x5B8F;&#x4EFB;&#x52A1;&#xFF0C;&#x8F93;&#x51FA;4</li>
</ol>
<p><img src="https://github.com/woai3c/Front-end-articles/blob/master/imgs/eventloop.svg" alt="eventloop"></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="eslint-vscode-format.html" class="navigation navigation-prev " aria-label="Previous page: Eslint Vscode Format">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="four-operations-1.html" class="navigation navigation-next " aria-label="Next page: Four Operations 1">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Eventloop","level":"1.14","depth":1,"next":{"title":"Four Operations 1","level":"1.15","depth":1,"path":"前端进阶/four-operations-1.md","ref":"前端进阶/four-operations-1.md","articles":[]},"previous":{"title":"Eslint Vscode Format","level":"1.13","depth":1,"path":"前端进阶/eslint-vscode-format.md","ref":"前端进阶/eslint-vscode-format.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["summary","livereload"],"pluginsConfig":{"summary":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"前端进阶/eventloop.md","mtime":"2021-02-15T12:04:36.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-03-24T08:50:55.666Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

